<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>人工导出情况列表</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="../../static/js/avalon.js"></script>
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->
</head>

<body>


    <div class="layui-fluid" ms-controller="test">
        <div class="layui-card content-wrap">
            <!--查询-->
            <!--<div class="layui-form layui-card-header layuiadmin-card-header-auto">-->
            <form class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-sm4">
                            <label class="layui-form-label">流水号</label>
                            <div class="layui-input-block">
                                <input type="text" id="serialNumber" placeholder="请输入流水号" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-col-sm4">
                            <label class="layui-form-label">省份</label>
                            <div class="layui-input-block">
                                <select lay-filter="provinceSelect" id='optProvince' lay-verify="required">
                                    <option value="">请选择</option>
                                    <option ms-attr="{value: el.code}" ms-for="($index, el) in @provlist">{{el.name}}</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-col-sm4">
                            <label class="layui-form-label">市区</label>
                            <div class="layui-input-block">
                                <select lay-filter="regionSelect" id='optCity' lay-verify="required" name="cityCode">
                                    <option value="">请选择</option>
                                    <option ms-attr="{value: el.code}" ms-for="($index, el) in @regionlist">{{el.name}}</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-sm4">
                            <label class="layui-form-label">导出时间起</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" id="fromTime" placeholder="导出时间起" autocomplete="off">
                            </div>
                        </div>
                        <div class="layui-col-sm4">
                            <label class="layui-form-label">导出时间至</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" id="toTime" placeholder="导出时间止" autocomplete="off">
                            </div>
                        </div>
                        <div class="layui-col-sm4">

                            <a id="doSearch" class="layui-btn add_btn">
                                <i class="layui-icon layui-icon-search"></i>搜索</a>
                            <button type="reset" class="layui-btn delete_btn">
                                <i class="layui-icon layui-icon-delete"></i>清空</button>
                            <a id="doExport" class="layui-btn add_btn">
                                <i class="layui-icon layui-icon-search"></i>导出</a>
                        </div>

                    </div>
                </div>
            </form>


            <!--数据列表展示-->
            <div>
                <script type="text/html" id="optToolbar">
                <div style="padding-bottom: 10px;">
                    <button class="layui-btn layuiadmin-btn-useradmin delete_btn" lay-event="delRecord"><i class="layui-icon layui-icon-delete"></i>删除</button>
                    <button class="layui-btn layuiadmin-btn-useradmin add_btn" lay-event="viewRecord">查看</button>
                </div>
            </script>

                <table class="layui-hide" id="dataListTable" lay-filter="active"></table>
            </div>


        </div>
    </div>


</body>

<script>
    var table;
    var tableObj;
    var form;
    var vm = avalon.define({
        $id: "test",
        fromTime: '',
        toTime: '',
        provlist: [],
        regionlist: [],
        provinceid:'',
        cityid:'',
        //  查询省市区
        getprovlist: function () {
            ax.post({
                url:schoolWebUrl +  '/api/captcha/getRegionProvince',
                contentType: "application/x-www-form-urlencoded",
                data: '',
                success: function (r) {
                    vm.provinceid = "";
                    vm.provlist = r.data;
                    // vm.provinceid = r.data[0].code;
                    // vm.getRegionlist();
                    setTimeout(function () {
                        form.render('select');
                    },200);
                },
            });
        },
        // 获取市
        getRegionlist: function () {
            ax.post({
                url: schoolWebUrl + '/api/captcha/getRegionCode',
                contentType: "application/x-www-form-urlencoded",
                data: { "code": vm.provinceid },
                success: function (r) {
                    // vm.cityid = r.data[0].code;
                    vm.cityid = "";
                    vm.regionlist = r.data;
                    setTimeout(function () {
                        form.render('select');
                    },200);
                },
            });
        },
    });
    vm.$watch('onReady', function () {
        //获取省市区
        console.log(1)
        vm.getprovlist();

    });


    layui.use(['table', 'form', 'laydate', 'layer', 'element'], function () {
        table = layui.table;
        form = layui.form;

        var $ = layui.$,

            layDateFrom = layui.laydate,
            layDateTo = layui.laydate,
            layer = layui.layer;

        // 初始化日期控件
        var fromTime = layDateFrom.render({
            elem: '#fromTime',
            max:'nowTime',//默认最大值为当前日期
            done:function(value, date) {
                if(date.hasOwnProperty("year")) {
                    toTime.config.min={
                        year:date.year,
                        month:date.month-1,//关键
                        date:date.date,
                        hours:date.hours,
                        minutes:date.minutes,
                        seconds:date.seconds
                    };
                }
            }
        });
        var toTime = layDateTo.render({
            elem: '#toTime',
            max:'nowTime',//默认最大值为当前日期
            done:function(value, date) {
                if(date.hasOwnProperty("year")) {
                    fromTime.config.max={
                        year:date.year,
                        month:date.month-1,//关键
                        date:date.date,
                        hours:date.hours,
                        minutes:date.minutes,
                        seconds:date.seconds
                    };
                }
            }
        });

        $("#doExport").on("click", function () {


            index = top.layer.open({
                title: "导出审核结果",
                type: 2,
                fixed: true, //不固定
                maxmin: true,
                area: ['90%', '80%'],
                content: "./aos/review/exportScreen.html",
                success: function (layero, index) {
                    setTimeout(function () {
                        top.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    }, 500)
                }
            })

            return false;
        });

        tableObj = ax.VTable({
            id: 'loadDataList',
            elem: '#dataListTable',
            url: backendWebUrl + '/api/student/review/listExportRecord',
            toolbar: '#optToolbar',
            title: '导出记录列表',
            cols: [[
                { type: 'checkbox', fixed: 'left' },
                {type: 'numbers', width : 80, title : '序号', fixed : 'left'},
                { field: 'serialNumber', title: '流水号', width: 200, fixed: 'left' },
                { field: 'dataCount', width: 100, title: '数量' },
                { field: 'optCityName', width: 150, title: '省市' },
                { field: 'exportTime', width: 180, title: '导出时间' },
                { field: 'importTime', width: 180, title: '导入时间' }
            ]]

        });

        $('#doSearch').on('click', function () {
            searchData();
        });

        //头工具栏事件
        table.on('toolbar()', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'delRecord':
                    var data = checkStatus.data;
                    if (data.length <= 0) {
                        top.layer.open({
                            title: '信息提示'
                            , content: '请选择删除的数据！'
                        });
                        break;
                    }
                    top.layer.confirm('确定需要删除选中的导出记录！', function (index) {
                        var ids = [];
                        for (var i = 0; i < data.length; i++) {
                            ids.push(data[i].id);
                        }
                        delRecord(ids.join(","));
                    })

                    break;
                case 'viewRecord':
                    var data = checkStatus.data;
                    if (data.length <= 0) {
                        top.layer.open({
                            title: '信息提示'
                            , content: '请选择查看的数据！'
                        });
                        break;
                    }

                    window.location.href='exportSituation.html?id='+ data[0].id
                   
                    break;
            };
        });
        //省改变
        form.on('select(provinceSelect)', function (data) {
            vm.provinceid = data.value;
            vm.getRegionlist();
        });
        // 市改变
        form.on('select(regionSelect)', function (data) {
            vm.cityid = data.value;
        });

    });

    function searchData() {
        //执行重载
        tableObj.reload({
            page: {
                curr: 1 //重新从第 1 页开始
            },
            where: {
                serialNumber: $('#serialNumber').val(),
                provinceCode: vm.provinceid,
                cityCode: vm.cityid,
                fromTime: $('#fromTime').val(),
                toTime: $('#toTime').val()
            }
        });
    }

    //删除记录
    function delRecord(ids) {
        var data = { ids: ids };
        ax.get({
            url: backendWebUrl + "/api/student/review/deleteExportRecord",
            data: data,
            success: function (res) {
                if (res.code == 0) {
                    layer.msg("删除成功");
                    searchData();
                } else {
                    layer.msg(res.msg);
                }
            },
            error: function (request) {
                layer.msg("系统错误，联系管理员");
            }
        });
    }
</script>

</html>